<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
距离五一还有
<span></span>天
<span></span>时
<span></span>分
<span></span>秒
<script type="text/javascript">
	let span = document.querySelectorAll('span')

	function time(){
		let now = new Date().getTime()
		let endTime = new Date('2025/5/1,00:00:00').getTime()

		//获取五一到现在的时间差
		let diff = endTime - now
		// console.log(diff)

		//秒
		let count = diff/1000 

		let day = parseInt(count / 60 / 60 / 24)

		let hours = parseInt(count / 60 / 60 % 24)

		let minute = parseInt(count / 60 % 60)

		let seconds = parseInt(count % 60)

		hours = hours < 10 ? '0' + hours : hours
		minute = minute < 10 ? '0' + minute : minute
		seconds = seconds < 10 ? '0' + seconds : seconds

		span[0].innerText = day
		span[1].innerText = hours
		span[2].innerText = minute
		span[3].innerText = seconds
	}
	time()

let timeId = setInterval(time,1000)
	
</script>
</body>
</html>